const app = getApp();
const AJAX = app.$ajax,
  $wx = app.$wx;

Page({
  data: {
    imgHost: app.imgHost,
    estimateVal: ''
  },

  onLoad(options){
    
    this.getOrderList(options.commodity_index);
  },

  onShareAppMessage(){
    
  },

  estimate(e){
    let val = e.detail.value;

    this.setData({
      estimateVal: val
    });
  },

  uploadImgs(){
    $wx.uploadSourceType([], res => {
      let temp_file = res.tempFiles[0];
      $wx.uploadFile({
        url: AJAX.uploadFile,
        filePath: temp_file,
        name: 'file',
        complete(res) {
          let upload_res = JSON.parse(res.data);
          console.log(upload_res);
        }
      })
    });
  },

  submit(){
    let td = this.data;
    if(td.estimateVal.length === 0){
      $wx.showToast('请输入评价');
    }else{

    }
  },
  
  getOrderList(index) {
    AJAX.orderList({
      loadType: 'bar',
      status: 6
    }).then(([status, res, msg]) => {
      if (status) {
        this.setData({
          orderDetail: res[index]
        });
      } else {
        $wx.showToast(msg);
      }
    });
  }
});